package com.requiem.hist_group_manage_springboot.controller;

import com.requiem.hist_group_manage_springboot.exception.R;
import com.requiem.hist_group_manage_springboot.model.EvaluationModel;
import com.requiem.hist_group_manage_springboot.model.TeacherModel;
import com.requiem.hist_group_manage_springboot.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping({"/teacher"})
public class TeacherController {
    @Autowired
    TeacherService teacherService;

    @GetMapping({"/getList"})
    R getList() {
        return teacherService.getList();
    }

    @GetMapping({"/get"})
    R getByID() {
        return teacherService.getByID();
    }

    @GetMapping("/getLog")
    R getLog() {
        return teacherService.getLog();
    }

    @PostMapping({"/add"})
    R add(@RequestBody TeacherModel teacherModel) {
        return teacherService.add(teacherModel);
    }

    @DeleteMapping({"/delete"})
    R delete() {
        return teacherService.delete();
    }

    @PostMapping({"/edit"})
    R edit(@RequestBody TeacherModel teacherModel) {
        return teacherService.edit(teacherModel);
    }

    @PostMapping("/join")
    R joinGroup(@RequestParam int teacherID, String groupID) {
        return teacherService.joinGroup(teacherID, groupID);
    }

    @PostMapping("/exit")
    R exitGroup(@RequestParam int teacherID, String groupID) {
        return teacherService.exitGroup(teacherID, groupID);
    }

    @PostMapping("/Search")
    R getSearch(@RequestBody TeacherModel teacherModel) {
        return teacherService.SearchList(teacherModel);
    }

    /*
     * 评论功能
     */
    @GetMapping("/getStudent")
    R getStudent(@RequestParam String groupId) {
        return teacherService.getStudent(groupId);
    }

    @GetMapping("/getEvaluation")
    R getEvaluation(@RequestParam int teacherId) {
        return teacherService.getEvaluation(teacherId);
    }

    @PostMapping("/addEvaluation")
    R addEvaluation(@RequestBody EvaluationModel evaluationModel) {
        return teacherService.addEvaluation(evaluationModel);
    }

    //重置密码
    @PostMapping("/resetPassword")
    R resetPassword(@RequestParam int id, @RequestParam String password) {
        return teacherService.resetPassword(id, password);
    }
}
